package com.shixun.dds_11.controller;


import com.shixun.dds_11.JWT.JwtClaimsConstant;
import com.shixun.dds_11.JWT.JwtUtil;
import com.shixun.dds_11.entity.DdsUser;
import com.shixun.dds_11.result.Result;
import com.shixun.dds_11.service.IDdsUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YSP
 * @since 2024-07-05
 */
@Api(tags = {"用户登录接口"})
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/dds11/user")
public class DdsUserController {

    @Autowired
    IDdsUserService ddsUserService;

    /**
     * 用户注册
     * @param user
     * @return
     */
    @PostMapping("/register")
    @ApiOperation(value = "用户注册")
    public Result register(@RequestBody DdsUser user) {
        log.info("用户注册");
        ddsUserService.register(user);
        return Result.success();

    }

    /**
     * 用户登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    @ApiOperation(value = "用户登录")
    public Result login(@RequestBody DdsUser user) {
        log.info("用户登录");

        return ddsUserService.login(user);

    }

}
